<?php

/**
 * BlogArticle form.
 *
 * @package    blog
 * @subpackage form
 * @author     Your name here
 * @version    SVN: $Id: sfDoctrineFormTemplate.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
abstract class PluginBlogArticleForm extends BaseBlogArticleForm
{
	
	
	
  public function setup()
  {
	  parent::setup();
	  
	  $this->disableLocalCSRFProtection();
	 
    
     unset (
	 $this["id"], $this["created_at"], $this["updated_at"], $this["token"]
	  );
     
  
   $this->setWidget('content', new sfWidgetFormTextareaTinyMCE(
   
    array( 
        'theme'   =>  sfConfig::get('my_settings1','advanced'), 
         'config'=>'plugins:"bbcode"', 
        
        
      ), 
      array( 
        'class'   =>  'tiny_mce' 
      ) 
    )); 
   
  $this->setWidget('category_id', new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('BlogCategory'), 'add_empty' => false)));
   $this->setWidget('cover', new sfWidgetFormInputFile());
   $this->setWidget('title', new sfWidgetFormInputText());
   $this->setWidget('publied_at', new sfWidgetFormDate());
   
    $this->setWidget('user_id', new sfWidgetFormInputHidden());
    $this->setWidget('is_activated', new sfWidgetFormInputHidden());
   
   $this->widgetSchema->setNameFormat('article[%s]');
  $this->widgetSchema->setLabels(array(
  'category_id'    => 'Categorie',
  'title'   => 'Titre',
  'cover'   => 'Cover de l\'article',
  'content'   => 'Contenu',
   'publied_at'   => 'publier le',
));
  
  $this->setValidators(array(
       'id'    => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'title' => new sfValidatorString(array('min_length' => 2), array('required' => 'Le titre est obligatoire.')),
      'cover'    => new sfValidatorFile(array('required'   => false, 'path'=> sfConfig::get('sf_upload_dir').'/cover' )),
      'content' => new sfValidatorString(array('min_length' => 10), array('required' => 'Le contenu est obligatoire.', 'min_length' => '10 caractères minimum' )),
      'category_id'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('BlogCategory'))),
      'user_id'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('sfGuardUser'))),
      'publied_at'   => new sfValidatorDate(array('date_format' => '~(?P<day>\d{2})/(?P<month>\d{2})/(?P<year>\d{4})~')),
      'is_activated'      => new sfValidatorBoolean(array('required' => false)),
    ));
  
  
  
  }
  
   
}
